/*
 * Class name: 			MapUserToGroup
 * Class description: 	The MapUserToGroup class is a mapping from the user
 * 						table to many group tables. This was done to correspond
 * 						to the "many-to-many" relationship between users and groups
 * Project:				GrocerWE
 */

package com.cse210.grocerwe.common;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(detachable="true")
public class MapUserToGroup{
	
	//database primary key
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    
    //The User of this mapping
    @Persistent
    private String user;
    
    //The group the user is mapped to
    @Persistent
    private String group;
    
    
    /*
     * Constructor
     */
    public MapUserToGroup(String user, String group)
    {
    	this.user = user;
    	this.group = group;
    }
    
    /*
     * Getters
     */
    public String getKey()
    {
    	return KeyFactory.keyToString(key);
    }
    public String getUser()
    {
    	return user;
    }
    public String getGroup()
    {
    	return group;
    }
    
    /*
     * Setters
     */
    public void setUser(String user)
    {
    	this.user = user;
    }
    public void setGroup(String group)
    {
    	this.group = group;
    }
}
